<template>
	<view>
		<view class="box">
			<image :src="loginbanner" class="sign-banner" alt=""></image>
			<image :src="loginlogo" class="sign-logo" alt=""></image>
			<view class="sign-box">
				<h3>修改密码</h3>
				<view class="same-btn password ">
					<label class="iconfont iconfonts icon-ym-thecode"></label>
					<input type="password" v-model="Password" id="password" placeholder="设置登录密码(不少于6个字符)">
				</view>
				<view class="same-btn password passwordtwo">
					<label class="iconfont iconfonts icon-ym-thecode"></label>
					<input type="password" v-model="newPassword" id="password" placeholder="再次输入新密码">
				</view>
				<view class="sign-btn" @click="sure">
					确认
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import config from '@/common/js/config.js'
	import helper from '@/common/js/helper.js'
	export default {
		data() {
			return {
				lookpwd: true,
				load: false,
				Password: '',
				newPassword: '',
				user: {
					Password: '',
					SmsCode: '',
					Mobile: ''
				},
				loginbanner: config.Resources.banner.loginbanner,
				loginlogo: config.Resources.banner.loginlogo
			}
		},
		onLoad(e) {
			this.user.SmsCode = e.smscode;
			this.user.Mobile = e.mobile;
		},
		methods: {
			sure: function() {
				if (this.Password != this.newPassword) {
					helper.msg('两次密码不一致，重新输入');
					return;
				}
				this.user.Password = helper.calcuMD5(this.Password);
				// let apiKey= uni.getStorageSync('apiKey') ||'NET';
				// let baseUrlObj=config.Global.baseUrl;
				// let baseUrl=config.Global.baseUrl[apiKey].apiUrl;
				uni.request({
					method: 'POST',
					url: config.Global.baseUrl.NET.apiUrl + '/api/Saas/Tenant/UpdatePassword',
					data: this.user,
					header: {
						'content-type': 'application/x-www-form-urlencoded'
					},
					success: res => {
						if (res.data.code == 200) {
							uni.showToast({
								title: res.data.message,
								icon: "success",
								success: () => {
									uni.redirectTo({
										url: '/pages/users/sign-in/sign-in'
									});
								}
							});
						} else {
							helper.msg(res.data.message);
						}
					},
				});
			}
		}
	}
</script>

<style>
	.password {
		margin-bottom: 40upx;
	}

	.company {
		margin-bottom: 40upx;
	}

	.passwordtwo {
		margin-bottom: 170upx;
	}
</style>
